/**
 * 
 */
package pl.s7n.paint.edits;

import java.awt.Graphics2D;
import java.util.List;

import javax.swing.undo.UndoableEditSupport;

/**
 * Base class for edit manager. <br>
 * Actions are supposed to be stored in the actions list.<br>
 * They may be added on editPerformed() and redo() or removed on undo().<br>
 * 
 * @author 7
 * @param <T>
 *          the base class of commands to handle
 */
public abstract class AbstractEditManager<T> {

  protected UndoableEditSupport undoableEditSupport;

  protected List<T>             actions;

  public AbstractEditManager(UndoableEditSupport undoableEditSupport) {
    this.undoableEditSupport = undoableEditSupport;
  }

  public void editPerformed(T action) {
    actions.add(action);
  }

  public void reset() {
    actions.clear();
  }

  public boolean hasActions() {
    return !actions.isEmpty();
  }
  
  public abstract void draw(Graphics2D g);
}
